home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / GUSI 1.4.1 / GUSI / include / GUSI.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-25  |  7.4 KB  |  300 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. Project    :    GUSI                -    Grand Unified Socket Interface
  3. File        :    GUSI.h            -    Socket calls
  4. Author    :    Matthias Neeracher
  5. Language    :    MPW C/C++
  6.  
  7. $Log: GUSI.h,v $
  8. Revision 1.1  1994/02/25  02:56:49  neeri
  9. Initial revision
  10.  
  11. Revision 0.15  1993/06/27  00:00:00  neeri
  12. f?truncate
  13.  
  14. Revision 0.14  1993/06/20  00:00:00  neeri
  15. Changed sa_constr_ppc
  16.  
  17. Revision 0.13  1993/02/14  00:00:00  neeri
  18. AF_PAP
  19.  
  20. Revision 0.12  1992/12/08  00:00:00  neeri
  21. getcwd()
  22.  
  23. Revision 0.11  1992/11/15  00:00:00  neeri
  24. remove netdb.h definitions
  25.  
  26. Revision 0.10  1992/09/26  00:00:00  neeri
  27. Separate dirent and stat
  28.  
  29. Revision 0.9  1992/09/12  00:00:00  neeri
  30. Hostname stuff
  31.  
  32. Revision 0.8  1992/09/07  00:00:00  neeri
  33. readlink()
  34.  
  35. Revision 0.7  1992/08/03  00:00:00  neeri
  36. sa_constr_ppc
  37.  
  38. Revision 0.6  1992/07/21  00:00:00  neeri
  39. sockaddr_atlk_sym
  40.  
  41. Revision 0.5  1992/06/26  00:00:00  neeri
  42. choose()
  43.  
  44. Revision 0.4  1992/05/18  00:00:00  neeri
  45. PPC stuff
  46.  
  47. Revision 0.3  1992/04/27  00:00:00  neeri
  48. getsockopt()
  49.  
  50. Revision 0.2  1992/04/19  00:00:00  neeri
  51. C++ compatibility
  52.  
  53. Revision 0.1  1992/04/17  00:00:00  neeri
  54. bzero()
  55.  
  56. *********************************************************************/
  57.  
  58. #ifndef _GUSI_
  59. #define _GUSI_
  60.  
  61. #include <sys/types.h>
  62.  
  63. /* Feel free to increase FD_SETSIZE as needed */
  64. #define GUSI_MAX_FD    FD_SETSIZE
  65.  
  66. #include <sys/cdefs.h>
  67. #include <compat.h>
  68. #include <sys/ioctl.h>
  69. #include <sys/fcntl.h>
  70. #include <sys/stat.h>
  71. #include <dirent.h>
  72. #include <Types.h>
  73. #include <Events.h>
  74. #include <Files.h>
  75. #include <AppleTalk.h>
  76. #include <CTBUtilities.h>
  77. #include <Packages.h>
  78. #include <PPCToolBox.h>
  79. #include <sys/time.h>
  80. #include <sys/socket.h>
  81. #include <string.h>
  82. #include <netinet/in.h>
  83. #include <netdb.h>
  84. #include <sys/un.h>
  85. #include <unistd.h>
  86. #include <machine/endian.h>
  87.  
  88. typedef enum spin_msg {
  89.     SP_MISC,                /* some weird thing, usually just return immediately if you get this */
  90.     SP_SELECT,            /* in a select call */
  91.     SP_NAME,                /* getting a host by name */
  92.     SP_ADDR,                /* getting a host by address */
  93.     SP_STREAM_READ,    /* Stream read call */
  94.     SP_STREAM_WRITE,    /* Stream write call */
  95.     SP_DGRAM_READ,        /* Datagram read call */
  96.     SP_DGRAM_WRITE,    /* Datagram write call */
  97.     SP_SLEEP,            /* sleeping, passes ticks left to sleep */
  98.     SP_AUTO_SPIN        /* Autospin, passes argument to SpinCursor */
  99. } spin_msg;
  100.  
  101. typedef int (*GUSISpinFn)(spin_msg msg, long param);
  102. typedef void (*GUSIEvtHandler)(EventRecord * ev);
  103. typedef GUSIEvtHandler    GUSIEvtTable[24];
  104.  
  105. /*
  106.  * Address families, defined in sys/socket.h
  107.  *
  108.  
  109. #define    AF_UNSPEC         0        // unspecified
  110. #define    AF_UNIX             1        // local to host (pipes, portals)
  111. #define    AF_INET             2        // internetwork: UDP, TCP, etc.
  112. #define    AF_CTB             3        // Apple Comm Toolbox (not yet supported)
  113. #define    AF_FILE             4        // Normal File I/O (used internally)
  114. #define    AF_PPC             5        // PPC Toolbox
  115. #define    AF_PAP             6        // Printer Access Protocol (client only)
  116. #define    AF_REMOTECON     7        // Remote Console (used internally)
  117. #define    AF_APPLETALK    16        // Apple Talk
  118.  
  119. */
  120.  
  121. #define    ATALK_SYMADDR 272        /* Symbolic Address for AppleTalk             */
  122.  
  123. /*
  124.  * Types,  defined in sys/socket.h
  125.  *
  126.  
  127. #define    SOCK_STREAM         1        // stream socket 
  128. #define    SOCK_DGRAM         2        // datagram socket
  129.  
  130. */
  131.  
  132. /*
  133.  * Defined in sys/un.h
  134.  *
  135.  
  136. struct sockaddr_un {
  137.     short        sun_family;
  138.     char         sun_path[108];
  139. };
  140.  
  141. */
  142.  
  143. struct sockaddr_atlk {
  144.     short            family;
  145.     AddrBlock    addr;
  146. };
  147.  
  148. struct sockaddr_atlk_sym {
  149.     short            family;
  150.     EntityName    name;
  151. };
  152.  
  153. struct sockaddr_ppc {
  154.     short                    family;
  155.     LocationNameRec    location;
  156.     PPCPortRec            port;
  157. };
  158.  
  159. /* Definitions for choose() */
  160.  
  161. #define     CHOOSE_DEFAULT    1        /*    Use *name as default name                        */
  162. #define    CHOOSE_NEW        2        /* Choose new entity name, not existing one    */
  163. #define    CHOOSE_DIR        4        /* Choose a directory name, not a file         */
  164.  
  165. typedef struct {
  166.     short            numTypes;
  167.     SFTypeList    types;
  168. } sa_constr_file;
  169.  
  170. typedef struct {
  171.     short            numTypes;
  172.     NLType        types;
  173. } sa_constr_atlk;
  174.  
  175. /* Definitions for sa_constr_ppc */
  176.  
  177. #define PPC_CON_NEWSTYLE        0x8000    /* Required */
  178. #define PPC_CON_MATCH_NAME        0x0001    /* Match name */
  179. #define PPC_CON_MATCH_TYPE     0x0002     /* Match port type */
  180. #define PPC_CON_MATCH_NBP        0x0004    /* Match NBP type */
  181.  
  182. typedef struct    {
  183.     short            flags;
  184.     Str32            nbpType;
  185.     PPCPortRec    match;
  186. } sa_constr_ppc;
  187.  
  188. __BEGIN_DECLS
  189. /* 
  190.  * IO/Socket stuff, defined elsewhere (unistd.h, sys/socket.h
  191.  *
  192.  
  193. int socket(int domain, int type, short protocol);
  194. int bind(int s, void *name, int namelen);
  195. int connect(int s, void *addr, int addrlen);
  196. int listen(int s, int qlen);
  197. int accept(int s, void *addr, int *addrlen);
  198. int close(int s);
  199. int read(int s, char *buffer, unsigned buflen);
  200. int readv(int s, struct iovec *iov, int count);
  201. int recv(int s, void *buffer, int buflen, int flags);
  202. int recvfrom(int s, void *buffer, int buflen, int flags, void *from, int *fromlen);
  203. int recvmsg(int s,struct msghdr *msg,int flags);
  204. int write(int s, const char *buffer, unsigned buflen);
  205. int writev(int s, struct iovec *iov, int count);
  206. int send(int s, void *buffer, int buflen, int flags);
  207. int sendto (int s, void *buffer, int buflen, int flags, void *to, int tolen);
  208. int sendmsg(int s,struct msghdr *msg,int flags);
  209. int select(int width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
  210. int getdtablesize(void);
  211. int getsockname(int s, void *name, int *namelen);
  212. int getpeername(int s, struct sockaddr *name, int *namelen);
  213. int shutdown(int s, int how);
  214. int fcntl(int s, unsigned int cmd, int arg);
  215. int dup(int s);
  216. int dup2(int s, int s1);
  217. int ioctl(int d, unsigned int request, long *argp);
  218. int getsockopt(int s, int level, int optname, char *optval, int * optlen);
  219. int setsockopt(int s, int level, int optname, char *optval, int optlen);
  220. int isatty(int);
  221. int remove(const char *filename);
  222. int rename(const char *oldname, const char *newname);
  223. int creat(const char*);
  224. int faccess(char*, unsigned int, long*);
  225. long lseek(int, long, int);
  226. int open(const char*, int);
  227. int unlink(char*);
  228. int symlink(char* linkto, char* linkname);
  229. int readlink(char* path, char* buf, int bufsiz);
  230. int truncate(char *path, long length);
  231. int ftruncate(int fd, long length);
  232. int chdir(char * path);
  233. int mkdir(char * path);
  234. int rmdir(char * path);
  235. char * getcwd(char * buf, int size);
  236. */
  237.  
  238. /* 
  239.  * Defined in stdio.h
  240.  *
  241.  
  242. void fsetfileinfo (char *filename, unsigned long newcreator, unsigned long newtype);
  243.  
  244. */
  245.  
  246. void fgetfileinfo (char *filename, unsigned long * creator, unsigned long * type);
  247.  
  248. int choose(
  249.         int         domain,
  250.         int         type,
  251.         char *     prompt,
  252.         void *     constraint,
  253.         int         flags,
  254.         void *     name,
  255.         int *     namelen);
  256.  
  257. /* 
  258.  * Hostname routines, defined in netdb.h
  259.  *
  260.  
  261. struct hostent * gethostbyname(char *name);
  262. struct hostent * gethostbyaddr(struct in_addr *addrP, int, int);
  263. int gethostname(char *machname, long buflen);
  264. struct servent * getservbyname (char * name, char * proto);
  265. struct protoent * getprotobyname(char * name);
  266.  
  267. */
  268.  
  269. char * inet_ntoa(struct in_addr inaddr);
  270. struct in_addr inet_addr(char *address);
  271.  
  272. /* 
  273.  * What to do when a routine blocks
  274.  */
  275.  
  276. void GUSISetSpin(GUSISpinFn routine);
  277. GUSISpinFn GUSIGetSpin(void);
  278. int GUSISetEvents(GUSIEvtTable table);
  279. GUSIEvtHandler * GUSIGetEvents(void);
  280.  
  281. extern GUSIEvtHandler    GUSISIOWEvents[];
  282.  
  283. /* Directory Stuff */
  284.  
  285. /* 
  286.  * BSD memory routines, defined in compat.h
  287.  *
  288.  
  289. #define index(a, b)                        strchr(a, b)
  290. #define rindex(a, b)                        strrchr(a, b)
  291. #define bzero(from, len)                 memset(from, 0, len)
  292. #define bcopy(from, to, len)            memcpy(to, from, len)
  293. #define bcmp(s1, s2, len)                memcmp(s1, s2, len)
  294. #define bfill(from, len, x)            memset(from, x, len)
  295.  
  296.  */
  297.  
  298. __END_DECLS
  299.  
  300. #endif /* !_GUSI_ */